home *** CD-ROM | disk | FTP | other *** search
File List | 1985-07-12 | 13.9 KB | 530 lines |
-
- Listing 1.
-
-
- 210 DEFINT A-Z
- 220 SCREEN 2 : CLS
- 230 FOR I = 0 TO 3*80 STEP 80 ' rows are 80 bytes apart
- 240 FOR S = &HB800 TO &HBA00 STEP &H200 ' even rows in B800
- 250 DEF SEG = S ' odd rows in BA00
- 260 READ B
- 270 POKE I,B ' store each byte into video buffer
- 280 NEXT S
- 290 NEXT
- 300 PRINT : PRINT
- 310 END
- 320 '
- 330 'dot data which defines the character 'A' ...
- 340 DATA &h18,&h3c,&h66,&h66,&h7e,&h66,&h66,&h66
-
-
-
- Listing 2.
-
-
- ; definitions for 8 by 8 characters 80h through FFh
- csdefs db 087h,033h,03Fh,033h,087h,0E7h,0F3h,087h ; 080h
- db 0FFh,099h,0FFh,099h,099h,099h,0C0h,0FFh ; 081h
- db 0F1h,0FFh,0C3h,099h,081h,09Fh,0C3h,0FFh ; 082h
- db 081h,03Ch,0C3h,0F9h,0C1h,099h,0C0h,0FFh ; 083h
-
- .
- .
- .
- db 087h,093h,093h,093h,093h,0FFh,0FFh,0FFh ; 0FCh
- db 08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh ; 0FDh
- db 0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh ; 0FEh
- db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 0FFh
-
-
- ; put CGA into All Points Addressible graphics mode so that DOS will use
- ; our character table
- mov al,6 ; 640x200 2color APA graphics
- mov ah,0
- int 10h
-
- ; point CGA graphics character generator to our character definitions
- mov dx,offset csdefs
- push cs
- pop ds ; DS:DX points to our table
- mov al,1Fh ; interrupt number
- mov ah,25h ; DOS function number
- int 21h
-
-
-
-
- Listing 3.
-
-
- ; definitions for 8 by 8 characters 00h through FFh
- csdefs db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 000h
- db 081h,07Eh,05Ah,07Eh,042h,066h,07Eh,081h ; 001h
- db 081h,000h,024h,000h,03Ch,018h,000h,081h ; 002h
- db 093h,001h,001h,001h,083h,0C7h,0EFh,0FFh ; 003h
- .
- .
- .
- db 089h,023h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 07Eh
- db 0FFh,0EFh,0C7h,093h,039h,039h,001h,0FFh ; 07Fh
- hi_half db 087h,033h,03Fh,033h,087h,0E7h,0F3h,087h ; 080h
- db 0FFh,099h,0FFh,099h,099h,099h,0C0h,0FFh ; 081h
- .
- .
- .
- db 087h,093h,093h,093h,093h,0FFh,0FFh,0FFh ; 0FCh
- db 08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh ; 0FDh
- db 0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh ; 0FEh
- db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 0FFh
-
-
- ; put EGA into All Points Addressible graphics mode so that DOS will use
- ; our character table
- mov al,6 ; 640x200 2color APA graphics
- mov ah,0
- int 10h
-
- ; point EGA graphics character generator to our character definitions
- mov bp,offset csdefs
- push cs
- pop es ; ES:BP points to our table
- mov cx,8 ; CX := bytes/character in table
- è mov bl,0 ; BL := 0 (BIOS will use DL for
- ; number of rows on screen)
- mov dl,19h ; DL := 25 (number of character rows
- ; on screen)
- mov al,21h ; "user graphics character load"
- mov ah,11h ; BIOS "character generator routine"
- int 10h ; call EGA BIOS
-
- ; for compatibility, point interrupt 1Fh vector to characters 80h - FFh
- mov bp,offset hi_half
- push cs
- pop es ; ES:BP -> 2nd half of table
- mov al,20h ; "int 1Fh load"
- mov ah,11h
- int 10h
-
-
-
-
- Listing 4.
-
- ; definitions for 8 by 8 characters 00h through FFh
- csdefs db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 000h
- db 081h,07Eh,05Ah,07Eh,042h,066h,07Eh,081h ; 001h
- db 081h,000h,024h,000h,03Ch,018h,000h,081h ; 002h
- db 093h,001h,001h,001h,083h,0C7h,0EFh,0FFh ; 003h
- .
- .
- .
- db 087h,093h,093h,093h,093h,0FFh,0FFh,0FFh ; 0FCh
- db 08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh ; 0FDh
- db 0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh ; 0FEh
- db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ; 0FFh
-
-
- ; call BIOS to copy our definitions into character generator RAM area in
- ; bit plane 2
- mov bp,offset csdefs
- push cs
- pop es ; ES:BP points to our table
- mov cx,256 ; CX := number of characters defined
- ; in table
- mov dx,0 ; DX := character offset in table
- mov bl,0 ; BL := number of table to load (must
- ; be 0-3)
- mov bh,8 ; BH := # bytes/character in table
- mov al,10h ; "user alpha load"
- è mov ah,11h ; BIOS "character generator routine"
- int 10h ; call EGA BIOS
-
- ; update BIOS RAM area in segment 40h
- mov ax,40h
- mov ds,ax
-
- mov word ptr ds:[4Ah],80 ; update CRT_COLS (number of character
- ; columns on the display)
- mov word ptr ds:[4Ch],1C00h ; update CRT_LEN (80 rows * 43 columns
- ; * 2 bytes/character, rounded up to
- ; next even 1K boundary)
-
-
- Listing 5.
-
- csdefs db 000h,000h,000h,000h,000h,000h,000h,000h ; 000h
- db 8 dup(0)
- è db 07Eh,081h,0A5h,081h,0BDh,099h,081h,07Eh ; 001h
- db 8 dup(0)
- db 07Eh,0FFh,0DBh,0FFh,0C3h,0E7h,0FFh,07Eh ; 002h
- db 8 dup(0)
- .
- .
- .
-
- db 070h,018h,030h,060h,078h,000h,000h,000h ; 0FDh
- db 8 dup(0)
- db 000h,000h,03Ch,03Ch,03Ch,03Ch,000h,000h ; 0FEh
- db 8 dup(0)
- db 000h,000h,000h,000h,000h,000h,000h,000h ; 0FFh
- db 8 dup(0)
-
-
- ; set configuration switch on HGC Plus
- mov dx,3BFh ; i/o port address
- mov al,1 ; activate RAM from B000:0000
- out dx,al ; through B000:7FFF
-
- ; copy character definition table to B000:4000
- mov ax,0B000h
- mov es,ax
- mov di,4000h ; ES:DI := B000:4000
-
- push cs
- pop ds
- mov si,offset csdefs ; DS:SI -> our character def table
-
- mov cx,4096 ; CX := size of table in bytes
- rep movsb ; copy the table
-
- ; Program the CRT controller to display 43 lines of 8 by 8 characters.
- ; Characters are displayed in a 9x8 matrix for better appearance.
- ;
- mov dx,3B4h ; CRT controller register index port
-
- mov si,offset regs00_0D ; DS:SI -> start of table of register
- ; values
-
- mov cx,0Eh ; CX := loop counter
- xor ah,ah ; AH := 0 (initial CRT controller
- ; register number)
- label2: mov al,ah
- out dx,al ; store CRT controller index reg
-
- lodsb ; AL := data for CRT controller reg
- inc dx ; DX := 3B5h (CRT data reg port)
- out dx,al ; store data to CRT controller reg
- dec dx ; DX := 3B4h
-
- è inc ah ; AH := next CRT controller index #
- loop label2
-
- mov al,14h ; xModeReg index number
- out dx,al
-
- lodsb
- inc dx
- out dx,al ; configure xModeReg for RAM character
- ; set and proper character width
-
- ; update BIOS RAM area in segment 40h
- mov ax,40h
- mov ds,ax
-
- mov word ptr ds:[4Ah],80 ; update CRT_COLS (80 columns)
- mov word ptr ds:[4Ch],1C00h ; update CRT_LEN (80 columns * 43 rows
- ; * 2 bytes/character, rounded up to
- ; even 1K boundary)
-
- .
- .
- .
-
- ; table of CRT controller register values
-
- regs00_0D db 61h,50h,52h,0Fh ; regs 0 - 3 (9 wide)
- db 2Dh,02h,2Bh,2Ch ; regs 4 - 7 (8 high)
- db 02h,07h,06h,07h ; regs 8 - 0Bh (scans/char,
- ; cursor location)
- db 00h,00h ; regs 0Ch - 0Dh (always zero)
-
- xModeReg db 01h ; "4K RamFont", 9 dot wide
- ; characters
-
-
-
- Listing 6.
-
- cset0 equ 0 ; character generator RAM bank #'s
- cset1 equ 1
- .
- .
- .
-
-
- ; 1st 256 characters are 9x14 ROM characters (default for 350-line display)
- mov bl,cset0 ; indicate bank 0 of char generator RAM
- ; (A000:0000 in bit plane 2)
- mov al,1 ; indicate 8x14 ROM characters
- mov ah,11h
- int 10h ; call BIOS to load character table
-
- ; 2nd 256 characters are 8x8 ROM character set
- mov bl,cset1 ; indicate bank 1 of char gen RAM
- ; (A000:4000 in bit plane 2)
- mov al,2 ; indicate 8x8 ROM characters
- mov ah,11h
- int 10h
-
- ; Enable attribute bit 3 selection of character set
- mov bl,(cset1 shl 2)+cset0 ; BL := value for Sequencer Character
- ; Map Select register
- mov al,3 ; "set block specifier"
- mov ah,11h
- int 10h ; call BIOS to program Sequencer
-
- ; Disable bit 3 of attribute byte for palette selection
- mov bh,7 ; bit mask
- mov bl,12h ; Attribute Controller: Color Plane
- ; Enable register number
- mov al,0 ; "individual palette register"
- mov ah,10h
- int 10h ; call BIOS to set register
-
- ; Display a message
- push cs
- pop ds
-
- mov si,offset csmsg0
- mov bl,7 ; bit 3 of attribute = 0
- mov cx,25 ; length of string
- call show ; display string using char set 0
-
- è
- mov si,offset csmsg1
- mov bl,0Fh ; bit 3 of attribute = 1
- mov cx,25
- call show ; display string using char set 1
- .
- .
- .
-
-
- ; Subroutine which displays a string using a given attribute
-
- show proc near ; Caller: DS:SI -> string
- ; CX = length of string
- ; BL = attribute
- jcxz show2
-
- show1: lodsb ; AL := next char
- push cx
- push bx
- call emit ; display this character
- pop bx
- pop cx
- loop show1
-
- show2: ret
-
- show endp
-
-
- ; Subroutine which displays a single character using a given attribute
-
- emit proc near ; Caller: AL = character
- ; BL = attribute
- ; Returns: nothing, but advances
- ; the cursor
- push bx
- push cx
-
- cmp al,20h
- jb emit1 ; jump if control character
-
- push ax ; save char on stack
- mov cx,1 ; CX := # of chars to write
- mov bh,0 ; BH := video display page 0
- mov ah,9 ; call BIOS to write attribute and
- int 10h ; character at cursor
- pop ax ; AL := character
-
- emit1: mov ah,0Eh ; call BIOS to rewrite character in
- int 10h ; "teletype mode" which advances
- ; the cursor
- pop cx
- è pop bx
- ret
-
- emit endp
-
-
- ; Strings to be displayed
-
- csmsg0 db 'This is character set 0',0Dh,0Ah
- csmsg1 db 'This is character set 1',0Dh,0Ah
-
-
-
- Listing 7.
-
- ; set configuration switch on HGC Plus
- label0: mov dx,3BFh ; i/o port address
- mov al,1 ; activate RAM from B000:0000
- out dx,al ; through B000:7FFF
-
- ; Copy 1st 256 character definitions into character generator RAM from BIOS ROM
- mov ax,0F000h
- mov ds,ax
- mov si,0FA6Eh ; DS:SI -> start of 8x8 character
- ; definition table in ROM
- mov ax,0B000h
- mov es,ax
- mov di,4000h ; ES:DI -> start of Hercules font
- è ; definition storage area
-
- xor al,al ; AL := zero byte (used for padding)
- mov cx,256 ; CX := # of characters in table
-
- label1: push cx ; preserve loop counter
-
- mov cx,8 ; CX := # of bytes in one character
- ; definition
- rep movsb ; copy to HGC font storage area
-
- mov cx,8 ; CX := # of bytes of padding
- rep stosb ; store zeroes
-
- pop cx ; loop across all 256 characters
- loop label1
-
- ; Copy 2nd 256 character definitions into character generator RAM
- mov ax,0B000h
- mov ds,ax
- mov si,4000h ; DS:SI -> start of 8x8 character
- ; definition table in HGC Plus RAM
- mov cx,256*16 ; CX := size of 256-character table
-
- label2: lodsb ; copy "reverse" of 1st 256 chars ...
- not al
- stosb ; .. into table for 2nd 256 chars
- loop label2
-
- ; Program the CRT controller to display 25 lines of 8 by 14 characters.
- mov dx,3B4h ; CRT controller register index port
-
- push cs
- pop ds
- mov si,offset regs00_0D ; DS:SI -> start of table of register
- ; values
-
- mov cx,0Eh ; CX := loop counter
- xor ah,ah ; AH := 0 (initial CRT controller
- ; register number)
- label3: mov al,ah
- out dx,al ; store CRT controller index reg
-
- lodsb ; AL := data for CRT controller reg
- inc dx ; DX := 3B5h (CRT data reg port)
- out dx,al ; store data to CRT controller reg
- dec dx ; DX := 3B4h
-
- inc ah ; AH := next CRT controller index #
- loop label3
-
- mov cx,3
- mov ah,14h ; index value for xModeReg
-
- label4: mov al,ah ; Same loop for extra CRT controller ..
- è out dx,al ; .. regs used with extended ..
- ; .. character set
- lodsb
- inc dx
- out dx,al
- dec dx
-
- inc ah
- loop label4
-
- ; Update BIOS RAM area in segment 40h
- mov ax,40h
- mov ds,ax
- mov word ptr ds:[4Ah],90 ; CRT_COLS := 90
- mov word ptr ds:[4Ch],1400h ; CRT_LEN := 90 columns * 25 rows
- ; * 2 bytes/char, rounded up to next
- ; higher 1K
- ; Display a message
- push cs
- pop ds
- mov dx,1859h ; use BIOS scroll routine ...
- mov cx,0 ; .. to set attribute bytes in ..
- mov bh,0 ; .. display buffer to zero
- mov ax,600h
- int 10h
-
- mov si,offset csmsg0 ; 1st message
- mov bl,0 ; BL (high nibble) := 0 (normal attrib)
- ; BL (low nibble) := 0 (1st 256 chars)
- mov cx,48 ; length of string
- call show ; display string using char set 0
-
-
- mov si,offset csmsg1 ; 2nd message
- mov bl,81h ; BL (hi nibble) := 8 (intense video)
- ; BL (lo nibble) := 1 (2nd 256 chars)
- mov cx,49
- call show ; display string using char set 1
-
- .
- .
- .
-
-
- ; Subroutine which displays a string using a given attribute
-
- show proc near ; Caller: DS:SI -> string
- ; CX = length of string
- ; BL = attribute
- jcxz show2
-
- show1: lodsb ; AL := next char
- call emit ; display this character
- loop show1
-
- show2: ret
-
- show endp
-
-
- ; Subroutine which displays a single character using a given attribute
- ; Bits 0-3 of the attribute byte and bits 0-7 of the character form an
- ; 12-bit extended character code. Bits 4-7 of the attribute byte determine
- ; the actual attribute displayed.
-
- emit proc near ; Caller: AL = character
- ; BL = attribute
- ; Returns: nothing, but advances
- ; the cursor
- push bx
- push cx
-
- cmp al,20h
- jb emit1 ; jump if control character
-
- push ax ; save char on stack
- mov cx,1 ; CX := # of chars to write
- mov bh,0 ; BH := video display page 0
- mov ah,9 ; call BIOS to write attribute and
- int 10h ; character at cursor
- pop ax ; AL := character
-
- emit1: mov ah,0Eh ; call BIOS to rewrite character in
- int 10h ; "teletype mode" which advances
- ; the cursor
- pop cx
- pop bx
- ret
-
- emit endp
- è
-
- ; table of CRT controller register values
-
- regs00_0D db 6Dh,5Ah,5Ch,0Fh ; regs 0 - 3 (8 wide)
- db 19h,06h,19h,19h ; regs 4 - 7 (14 high)
- db 02h,0Dh,0Ch,0Dh ; regs 8 - 0Bh (scans/char,
- ; cursor location)
- db 00h,00h ; regs 0Ch - 0Dh (always zero)
-
- xModeReg db 07h ; "48K RamFont", 8 dot wide
- ; characters
- ScoreReg db 0Dh ; underscore reg
- StrikeReg db 06h ; overstrike reg
-
- ; Strings to be displayed
-
- csmsg0 db 'These characters are in the first group of 256',0Dh,0Ah
- csmsg1 db 'These characters are in the second group of 256',0Dh,0Ah
- KeyMsg db 0Dh,0Ah,'Press any key to continue ...',0Dh,0Ah